package com.jinmdz.fmis.mapper.mapper;

import org.apache.ibatis.annotations.*;
import com.jinmdz.fmis.mapper.mapper.provider.FamilyMemberProvider;
import com.jinmdz.fmis.mapper.entity.FamilyMemberEntity;

import java.util.ArrayList;

/**
 * 家属表Mapper
 * 
 * @author generator
 * @date 2020-08-23 18:11
 */
public interface FamilyMemberMapper {

    /**
     * 增加FamilyMember
     * 
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @InsertProvider(type = FamilyMemberProvider.class, method = "insertFamilyMember")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertFamilyMember(@Param("entity") FamilyMemberEntity entity);

    /**
     * 删除FamilyMember
     * 
     * @param id 主键
     * @param modifiedUserId 修改用户外键
     * @param version 版本号
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @Update(" update family_member set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForFamilyMember(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改FamilyMember
     * 
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @UpdateProvider(type = FamilyMemberProvider.class, method = "updateFamilyMember")
    void updateFamilyMember(@Param("entity") FamilyMemberEntity entity);

    /**
     * 查询FamilyMember实体
     * 
     * @param id 主键
     * @return FamilyMemberEntity
     * @author generator
     * @date 2020-08-23 18:11
     */
    @Select(" select id,deleted,business_code,member_name,member_gender_code,certificate_type_code,certificate_no,member_name_unison,member_name_abbr,member_relation,mobile_phone,other_phone,address,remark,as_recognition,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from family_member where id = #{id} and deleted = 0 limit 1 ")
    FamilyMemberEntity getFamilyMemberById(@Param("id") Integer id);

    /**
     * 查询FamilyMember列表
     * 
     * @param entity 数据实体
     * @return FamilyMemberEntity
     * @author generator
     * @date 2020-08-23 18:11
     */
    @SelectProvider(type = FamilyMemberProvider.class, method = "listFamilyMember")
    ArrayList<FamilyMemberEntity> listFamilyMember(@Param("entity") FamilyMemberEntity entity);
}